import http from '@/utils/request'

/**
 * 获取企业的部门列表
 */
export const reqGetDepartment = () => http.get('/company/department')

/**
 * 根据ID删除部门
 * @param {*} id 部门的id
 */
export const reqDelDepartment = (id) => {
  return http({
    method: 'delete',
    url: `/company/department/${id}`
  })
}

/**
 * 新增部门
 * @param {*} data {code, introduce, manager, name, pid}
 */
export const reqAddDepartment = (data) => {
  return http({
    method: 'post',
    url: '/company/department',
    data
  })
}

/**
 * 根据ID查询部门详情
 * @param {*} id 部门的id
 */
export const reqGetDepartDetail = (id) => {
  return http({
    method: 'get',
    url: `/company/department/${id}`
  })
}

/**
 * 根据ID修改部门详情
 * @param {*} form 收集的表单数据
 */
export const reqUpdateDepartDetail = (form) => {
  return http({
    method: 'put',
    url: `/company/department/${form.id}`,
    data: form
  })
}

// export const reqUpdateDepartDetail = (form) => http.put(`/company/department/${form.id}`, form)
